deserializeConfig

Deserializes a config from a string.

Extension of deserializeFromToml that deserializes directly from a string. Use to read from a file or packet.

Return

Returns ValidationResult of ConfigContext. The validation result includes the config and any applicable errors, and any flag information

Author

fzzyhmstrs

Since

0.7.0

Parameters

T

the config type. can be Any non-null type.

config

the config pre-deserialization

string

the string to deserialize from. Needs to be valid Toml.

errorBuilder

ValidationResult.ErrorEntry.Mutable instance that the deserializer will apply errors to and then use when building it's ValidationResult. Using ValidationResult.createMutable() is a good way to provide a fresh empty mutable error, with an optional header error message.

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4


fun <T : Any> deserializeConfig(config: T, string: String, errorHeader: String = "", flags: Byte = 1): ValidationResult<T>

Deserializes a config from a string.

Extension of deserializeFromToml that deserializes directly from a string. Use to read from a file or packet.

Return

Returns ValidationResult of ConfigContext. The validation result includes the config and any applicable errors, and any flag information

Author

fzzyhmstrs

Since

0.7.0

Parameters

T

the config type. can be Any non-null type.

config

the config pre-deserialization

string

the string to deserialize from. Needs to be valid Toml.

errorHeader

String header message that the deserializer will use when building it's ValidationResult.

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4


fun <T : Any> deserializeConfig(config: T, string: String, errorBuilder: MutableList<String>, flags: Byte = 1): ValidationResult<ConfigContext<T>>

Deprecated

Use overload that takes a ValidationResult.ErrorEntry.Mutable. Scheduled for removal 0.8.0

Deserializes a config from a string.

Extension of deserializeFromToml that deserializes directly from a string. Use to read from a file or packet.

Return

Returns ValidationResult of ConfigContext. The validation result includes the config and any applicable errors, and any flag information

Author

fzzyhmstrs

Since

0.2.0, deprecated 0.7.0 and scheduled for removal 0.8.0

Parameters

T

the config type. can be Any non-null type.

config

the config pre-deserialization

string

the string to deserialize from. Needs to be valid Toml.

errorBuilder

a mutableList of strings the original caller of deserialization can use to print a detailed error log

flags

default IGNORE_NON_SYNC. With the default, elements with the NonSync annotation will be skipped. See the flag options below to serialize the entire config (ex: saving to file), fully syncing (ex: initial sync server -> client), etc.

  • CHECK_NON_SYNC: Byte = 0

  • IGNORE_NON_SYNC: Byte = 1

  • CHECK_RESTART: Byte = 2

  • IGNORE_NON_SYNC_AND_CHECK_RESTART: Byte = 3

  • IGNORE_VISIBILITY: Byte = 4